<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="ko">
<head>
    <%@ include file="/include/header.jsp" %>
	<%@ include file="/include/commonRes.jsp" %>
	<link rel="stylesheet" href="<%=cp %>/css/default.css">
    <link rel="stylesheet" href="<%=cp %>/css/board.css">
    
    <link rel="stylesheet" href="<%=cp %>/css/other.css">
    <script type="text/javascript">
    	$(function(){
    		$("#btn_edit").click(function(){
    			
   				
				var personScore5 = $("input[name='personScore5']:checked");
				var personScore5_val=personScore5.val();
				
				if(personScore5_val==null ||personScore5_val==""){
					alert("오늘의 집중한 근무영역 만족도 점수를 선택해주세요.");
					return false;
				}
   					
   				
   				var bizNo1=1;
   				
   				var answer11=$("input[name='answer11']").val();
   				var answer12=$("input[name='answer12']").val();
   				var answer13=$("input[name='answer13']").val();
   				var answer14=$("input[name='answer14']").val();
   				
   				var bizNo2=2;
   				var answer21=$("input[name='answer21']").val();
   				var answer22=$("input[name='answer22']").val();
   				var answer23=$("input[name='answer23']").val();
   				var answer24=$("input[name='answer24']").val();
				
   				
   				var paramData={
					"bizNo1":bizNo1,
					"answer11":answer11,
					"answer12":answer12,
					"answer13":answer13,
					"answer14":answer14,
					"bizNo2":bizNo2,
					"answer21":answer21,
					"answer22":answer22,
					"answer23":answer23,
					"answer24":answer24
				};
				
				var success=function(data){
					if(data.resultCode=="0000"){
		   				if(!confirm("저장 하시겠습니까?")) {
		   					return false;
		   				}
						$("#editForm").submit();
					} else {
						alert(data.resultName);
						if(data.resultCode=="0001"){
							$("input[name='answer11']").focus();
						} else if(data.resultCode=="0002"){
							$("input[name='answer21']").focus();
						}
						return false;
					}
					
				}
				var error=function(xhr,error,response){
					alert("시스템 오류입니다. 다시 시도해주세요.");
				}
				var dataType="json";
				var type="POST";
				var url="<%=cp%>/org/orglist_check.do";
				sendAjax(type,dataType,url,paramData,success,error);
				
				
				
   				
    			
    			return false;
    		});
    		
			$("#btn_cancel").click(function(){
    			history.back();
    			return false;
    		});
            
			$("input.ymd").click(function(){
				$(this).val("");
			});	
           	$("input.ymd").datepicker({   // inputbox 의 id 가 startDate 이겠죠.
            	dateFormat:'yy-mm-dd' // 만약 2011년 4월 29일 선택하면  inputbox 에 '2011/04/29' 로표시
                //, showOn: 'button' // 우측에 달력 icon 을 보인다.
               // , buttonImage: '/images/Icon_calendar.gif'  // 우측 달력 icon 의 이미지 패스 
                //, buttonImageOnly: true //  inputbox 뒤에 달력icon만 표시한다. ('...' 표시생략)
                , changeMonth: true // 월선택 select box 표시 (기본은 false)
                ,changeYear: true  // 년선택 selectbox 표시 (기본은 false)
                ,showButtonPanel: true // 하단 today, done  버튼기능 추가 표시 (기본은 false)
            }); 

            
            $('img.ui-datepicker-trigger').attr('align', 'absmiddle'); // css 문제가 있는경우 일부 위치 조절 :)
        });
    </script>
</head>
<body>
	<div id="hd_login_msg">${sessionScope.ss_mb.mb_name} 로그인 중 <a href="<%=cp %>/logout.do">로그아웃</a></div>
	<%@include file="/include/mainMenuHeader.jsp" %>
	<div id="wrapper">
		<h2>나의 Teamtouch</h2> 
		<form id="editForm" name="editForm" action="<%=cp%>/teamt/teamt_edit.do" method="post">
			<div class="T_date">	     
			     <span>Teamtouch : </span>
			     <span>
			        ${paramDay }
			        <input type="hidden" name="paramDay" value="${paramDay }">
			      </span>    
		    </div>
	    
		    <input type="hidden" name="mode" value="${mode }"/>
		    <input type="hidden" name="mb_id" value="${mb_id }"/>
		    
		    <c:forEach var="item" items="${qnaList }" varStatus="status">
	    		<!-- 질문 _0${item.bizNo } -->   
		    	
		       	
		       	<c:if test="${item.bizNo ==5 }">
		       		<div class="T_qna">
			       		<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
  						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
						       			
			       		<span class="Q">${item.bizNo }.  ${item.bizName }
				       		<c:if test="${not empty item.personScore}">
								<span class="A5_S">${item.personScore }점</span>
							</c:if>
				       	</span> 
				       	<div class="A_5">
							<span><input type="radio" name="personScore${item.bizNo }" value="1" <c:if test="${item.personScore==1 }">checked="checked"</c:if>> 1점</span>
							<span><input type="radio" name="personScore${item.bizNo }" value="2" <c:if test="${item.personScore==2 }">checked="checked"</c:if>> 2점</span>
							<span><input type="radio" name="personScore${item.bizNo }" value="3" <c:if test="${item.personScore==3 }">checked="checked"</c:if>> 3점</span>
							<span><input type="radio" name="personScore${item.bizNo }" value="4" <c:if test="${item.personScore==4 }">checked="checked"</c:if>> 4점</span>
							<span><input type="radio" name="personScore${item.bizNo }" value="5" <c:if test="${item.personScore==5 }">checked="checked"</c:if>> 5점</span>
						</div>
					</div>
		       	</c:if>
		       	<c:if test="${item.bizNo !=5 }">
		       		
		       	
		       		<c:if test="${item.bizNo==1 ||item.bizNo==2 }">
		       			<c:if test="${empty questionsList }">
		       				<c:if test="${item.bizNo==1}">
					       		<div class="T_qna">
					       			<span class="Q">${item.bizNo }.  ${item.bizName }</span> 
					       			<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
		    						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
					       			<input type="text" name="answer11"  value="" />
					       			<input type="text" name="answer12"  value="" />
					       			<input type="text" name="answer13"  value="" />
					       			<input type="text" name="answer14"  value="" />
					       		</div>
					       	</c:if>
					       	<c:if test="${item.bizNo==2}">
					       		<div class="T_qna">
					       			<span class="Q">${item.bizNo }.  ${item.bizName }</span> 
					       			<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
		    						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
					       			<input type="text" name="answer21"  value="" />
					       			<input type="text" name="answer22"  value="" />
					       			<input type="text" name="answer23"  value="" />
					       			<input type="text" name="answer24"  value="" />
					       		</div>
					       	</c:if>
		       			</c:if>
		       			
		       			<c:if test="${not empty questionsList }">
		       				
		       				<c:forEach var="item1" items="${questionsList }" varStatus="status1">
				       			<c:if test="${item.bizNo==1 && item.bizNo==item1.bizNo}">
						       		<div class="T_qna">
						       			<span class="Q">${item.bizNo }.  ${item.bizName }</span> 
						       			<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
			    						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
						       			<input type="text" name="answer11"  value="${item1.q_emp_name1 }" />
						       			<input type="text" name="answer12"  value="${item1.q_emp_name2 }" />
						       			<input type="text" name="answer13"  value="${item1.q_emp_name3 }" />
						       			<input type="text" name="answer14"  value="${item1.q_emp_name4 }" />
						       		</div>
						       	</c:if>
						       	<c:if test="${item.bizNo==2 && item.bizNo==item1.bizNo}">
						       		<div class="T_qna">
						       			<span class="Q">${item.bizNo }.  ${item.bizName }</span> 
						       			<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
			    						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
						       			<input type="text" name="answer21"  value="${item1.q_emp_name1 }" />
						       			<input type="text" name="answer22"  value="${item1.q_emp_name2 }" />
						       			<input type="text" name="answer23"  value="${item1.q_emp_name3 }" />
						       			<input type="text" name="answer24"  value="${item1.q_emp_name4 }" />
						       		</div>
						       	</c:if>
				       		</c:forEach>
		       			</c:if>
		       		</c:if>
			       	
			       	<c:if test="${item.bizNo==3 }">
			       		<div class="T_qna">
			       			<span class="Q">${item.bizNo }.  ${item.bizName }</span> 
			       			<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
    						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
			       			<c:if test="${empty contactCustList }">
			       				<c:if test="${item.bizNo==3}">
					       			<input type="text" id="cust_name31" name="cust_name31" value="" />
		              				<input type="text" id="birthdayDate31" name="birthdayDate31" value="" class="ymd" readonly="readonly" />
		              				<input type="text" id="cust_name32" name="cust_name32" value="" />
		              				<input type="text" id="birthdayDate32" name="birthdayDate32" value="" class="ymd" readonly="readonly" />
		              				<input type="text" id="cust_name33" name="cust_name33" value="" />
		              				<input type="text" id="birthdayDate33" name="birthdayDate33" value="" class="ymd" readonly="readonly" />
	              				</c:if>
		       				</c:if>
		       				
			       			<c:if test="${not empty contactCustList }">
			       				<c:forEach var="item2" items="${contactCustList }" varStatus="status2">
					       			<c:if test="${item.bizNo==3 && item.bizNo==item2.bizNo}">
						       			<input type="text" id="cust_name3${status2.count }" name="cust_name3${status2.count }" value="${item2.cust_name }" />
			              				<input type="text" id="birthdayDate3${status2.count }" name="birthdayDate3${status2.count }" class="ymd" readonly="readonly" value="${item2.birthdayDate }" />
		              				</c:if>
	              				</c:forEach>
			       			</c:if>
			       		</div>
			       	</c:if>
			       	
			       	<c:if test="${item.bizNo==4 }">
			       		<div class="T_qna">
			       			<span class="Q">${item.bizNo }.  ${item.bizName }</span> 
			       			<input type="hidden" name="bizNo${item.bizNo }" value="${item.bizNo }"/> 
	   						<input type="hidden" name="bizName${item.bizNo }" value="${item.bizName }"/>
			       			
			       			<c:if test="${empty ideaList }">
			       				<textarea  name="answer41" class="A"></textarea>
			       				<textarea  name="answer42" class="A"></textarea>
			       				<textarea  name="answer43" class="A"></textarea>
			       			</c:if>		
			       			<c:if test="${not empty ideaList }">
			       				<c:forEach var="item3" items="${ideaList }" varStatus="status3">
					       			<textarea  name="answer4${status3.count }" class="A">${item3.teamtTouch_idea }</textarea>
				       			</c:forEach>
			       			</c:if>		
			       		</div>
			       	</c:if>
		       	</c:if>
		       	
		       <%-- 	<c:if test="${item.bizNo !=5 }">
			  		<textarea id="answer${item.bizNo }" name="answer${item.bizNo }" class="A">${item.answer }</textarea>
			  	</c:if>   --%>    
			  	
		   	
		   	<!-- <div class="borderDiv">&nbsp;</div>
		    <div class="score borderDiv">&nbsp;</div>
		   	<div class="borderDiv">&nbsp;</div>-->
		   	<!--//질문 _0${item.bizNo } --> 
	    
	    	</c:forEach>
   	 	</form>   
	</div>
   	<!-- 총평 --> 
   	<!-- <div class="T_speech">
        <span class="Qs">총 평</span>   
	  	<textarea name="answer" class="As"></textarea>      
   	</div> -->
   	<!-- //총평 -->  
   	<div class="right_area" >
   		<button id="btn_edit" type="button" class="btn_blue">저장</button>
   		<button id="btn_cancel" type="button" class="btn_gray">취소</button>
   	</div>  
</body>
</html>
